import { defineComponent as d, ref as c, onMounted as l, onBeforeUnmount as f, openBlock as p, createElementBlock as m, createElementVNode as w } from "vue";
const u = { id: "draw-panel" }, v = /* @__PURE__ */ d({
  __name: "drawPanel",
  props: {
    dataSrc: String
  },
  emits: ["closeHandle"],
  setup(n, { emit: r }) {
    const a = n, t = c(), o = r, i = (s) => {
      try {
        if (s.data && JSON.parse(s.data)) {
          const e = JSON.parse(s.data);
          e.event == "init" ? t.value.contentWindow.postMessage(
            JSON.stringify({
              action: "load",
              xmlpng: a.dataSrc
            }),
            "*"
          ) : e.event == "exit" ? o("closeHandle") : e.event == "save" ? t.value.contentWindow.postMessage(
            JSON.stringify({
              action: "export",
              format: "xmlpng",
              spinKey: "saving"
            }),
            "*"
          ) : e.event == "export" && o("closeHandle", e.data);
        }
      } catch (e) {
        console.log("err", e);
      }
    };
    return l(() => {
      window.addEventListener("message", i);
    }), f(() => {
      window.removeEventListener("message", i);
    }), (s, e) => (p(), m("div", u, [
      w("iframe", {
        src: "https://embed.diagrams.net/?embed=1&ui=atlas&spin=1&noSaveBtn=1&modified=unsavedChanges&proto=json",
        frameborder: "0",
        ref_key: "drawIframeRef",
        ref: t
      }, null, 512)
    ]));
  }
}), _ = (n, r) => {
  const a = n.__vccOpts || n;
  for (const [t, o] of r)
    a[t] = o;
  return a;
}, g = /* @__PURE__ */ _(v, [["__scopeId", "data-v-d12c86d7"]]), x = {
  // 定义install方法，接收vue作为参数，如果使用use注册插件，则组价都将被注册
  install: function(n) {
    n.component("PrawPanel", g);
  }
};
typeof window < "u" && window.Vue && window.Vue.use(x);
export {
  x as default
};
